home *** CD-ROM | disk | FTP | other *** search
- /* ========== the commmand file: ==========
-
- echo.c
-
- Copyright (c) 1993,1994 Newport Software Development
-
- You may distribute unmodified copies of this file for
- noncommercial purposes. You may use this file as a
- reference when writing your own nShell(tm) commands.
-
- All other rights are reserved.
-
- ========== the commmand file: ========== */
-
- #include "nshc.h"
- #include "str_utl.proto.h"
- #include "nshc_utl.proto.h"
-
- /* ======================================== */
-
- void add_char( Str255 string, char c, int *length );
-
- void add_char( Str255 string, char c, int *length )
- {
- if ( *length < 255 )
- string[ ++(*length) ] = c;
- else
- *length = 500;
- }
-
- /* ======================================== */
-
- void main(t_nshc_parms *nshc_parms, t_nshc_calls *nshc_calls)
- {
- int arg;
- int got_one;
- int length;
- char c;
- char *p;
- Str255 theString;
-
- if (nshc_bad_version( nshc_parms, nshc_calls, NSHC_VERSION )) return;
-
- nshc_parms->action = nsh_idle;
- nshc_parms->result = NSHC_NO_ERR;
-
- arg = 1;
- got_one = 0;
- length = 0;
- theString[0] = 0;
-
- while ( arg < nshc_parms->argc ) {
- if (got_one)
- add_char( theString, ' ', &length );
- p = &nshc_parms->arg_buf[nshc_parms->argv[arg]];
- while (c = *p++)
- add_char( theString, c, &length );
- got_one = 1;
- arg++;
- }
-
- if (got_one)
- if (length <= 255) {
- theString[0] = length;
- nshc_calls->NSH_putStr( theString );
- nshc_calls->NSH_putchar( '\r' );
- nshc_parms->result = NSHC_NO_ERR;
- }
- else{
- nshc_calls->NSH_putStr_err("\pecho: stdin exceeds 255 chars.\r");
- nshc_parms->result = NSHC_ERR_GENERAL;
- }
-
- }
-